package com.levi.fallback;

import com.levi.controller.order.OrderControllerApi;
import com.levi.vo.OrderDto;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author shentong
 * @since 2022/6/5 9:26 PM
 */
@Component
@Slf4j
public class OrderFallbackFactory implements FallbackFactory<OrderControllerApi> {
    @Override
    public OrderControllerApi create(Throwable throwable) {
        return new OrderControllerApi() {
            @Override
            public Boolean create(Integer id, Integer count) {
                System.out.println("出错了：=>>>>"+throwable);
                return false;
            }

            @Override
            public String gateway() {
                return "fallback gateway!!";
            }

            @Override
            public String index() {
                return "fallback index!!";
            }

            @Override
            public String createOrder(OrderDto orderDto) {
                return "fail";
            }
        };
    }
}
